<template>
    <div class="article-type-container">
        <div class="title">
            文章分类
        </div>
        <ul class="type-lists">
            <li :class="{
                active: route.params.categoryId ? false : true
            }">
                <router-link to="/article?page=1&limit=5">
                    <span>全部</span>
                    <span class="articleCount">{{ total }}篇</span>
                </router-link>
            </li>
            <li :class="{
                active: +route.params.categoryId === item.id
            }" v-for="(item, index) in data" :key="item?.id">
                <div @click="() => handleSelect(item.id)">
                    <span>{{ item?.name }}</span>
                    <span class="articleCount">{{ item?.articleCount }}篇</span>
                </div>
            </li>
        </ul>
    </div>
</template>

<script setup>
import { defineProps, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
const route = useRoute();
const { data, total, handleSelect } = defineProps({
    data: {
        type: Object,
        default: {}
    },
    total: {
        type: Number,
    },
    handleSelect: {
        type: Function,
    },

})
</script>

<style lang="less" scoped>
@import url("@/style/var.less");

.article-type-container {
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    scroll-behavior: smooth;

    .title {
        font-size: 17px;
        color: @words;
        font-weight: bold;
        margin-bottom: 20px;
    }

    .type-lists {
        width: 100%;

        li {
            min-height: 45px;
            line-height: 45px;
            cursor: pointer;

            &.active {
                font-weight: bold;
                color: @warn;

                span {
                    font-weight: bold;
                }
            }

            .articleCount {
                margin-left: 1em;
                font-size: 12px;
                color: @gray;
            }
        }
    }
}
</style>